import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;


public class Ex2_1 {
	
	public static void main(String[] args) {
		try {
			String sin = KmerCounter.readFile(
							"C:\\Users\\josemfer\\Downloads\\dataset_18_3.txt");
			HashMap<String,String> hm = 
						Ex2_1.createCodonList(
						"C:\\Users\\josemfer\\Downloads\\RNA_codon_table_1.txt");
			for (int i=0;i<sin.length();i=i+3) {
				String codon = sin.substring(i,i+3);
				if (hm.get(codon) == null) {
					break;
				}
				System.out.print(hm.get(codon));
			}			
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	public static HashMap<String, String> createCodonList(String file) 
			throws IOException {		
		HashMap<String, String> hm = new HashMap<String, String>();
		BufferedReader reader = new BufferedReader( new FileReader (file));
		String         line = null;				
		while( ( line = reader.readLine() ) != null ) {			
			String[] codon = line.split("\\s+");
			if (codon.length == 2) {
				hm.put(codon[0], codon[1]);
			} else if (codon.length == 1) {
				hm.put(codon[0], null);
			}					
		}		
		return hm;		
	}
	
	

}
